﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UricaoWeb.LogicaDeNegocios.Reservas;

namespace UricaoWeb.Presentacion
{
    public partial class API_reservar_RegistrarCliente : API_Seguridad_Principal
    {
        private LogicaReservas _logica = new LogicaReservas();

        protected void Page_Load(object sender, EventArgs e)
        {
            var master = Master as MasterPage;
            if (master != null)
            {
                master.actualizar_label();
            }
            base.validar_usuario();
        }

        /// <summary>
        /// Redirecciona a consultar reserva
        /// </summary>
        public static void Show(string message)
        {
            string cleanMessage = message.Replace("'", "\'");
            Page page = HttpContext.Current.CurrentHandler as Page;
            string script = string.Format("alert('{0}');", cleanMessage);
            if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
            {
                page.ClientScript.RegisterClientScriptBlock(page.GetType(), "alert", script, true /* addScriptTags */);
            }

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbNombre.Text) || string.IsNullOrEmpty(tbNombre.Text) || string.IsNullOrEmpty(tbApellido.Text) || string.IsNullOrEmpty(DDLTipoDoc.Text) || string.IsNullOrEmpty(tbDocumento.Text) || string.IsNullOrEmpty(DDLTipoPago.Text) || string.IsNullOrEmpty(tbCorreo.Text))
            {
                Show("¡ERROR!, ¡Verifique que los campos no esten vacios! y presione nuevamente");
            }
            else
            {
                bool _insertar = _logica.InsertarCliente(tbNombre.Text, tbApellido.Text, DDLTipoDoc.Text, tbDocumento.Text, DDLTipoPago.Text, tbCorreo.Text);
                Response.Redirect("http://localhost:11510/Presentacion/API_reservar_ReservarHabitacion.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("http://localhost:11510/Presentacion/API_reservar_PrincipalReservar.aspx");
        }

     

     
    }
}